/*
 * 版权所有 (c) 2022-2099 TBIT。保留所有权利。
 */

package com.tbit.uqbike.object.pojo.vo;

import com.alibaba.fastjson.annotation.JSONField;
import com.tbit.uqbike.annos.Excel;
import com.tbit.uqbike.constant.CsvConstant;
import com.tbit.uqbike.webmanager.util.csv.annotations.Csv;
import com.tbit.uqbike.webmanager.util.csv.annotations.Sum;
import lombok.Data;

import java.util.Date;

/**
 * 分账用户退款明细
 *
 * @Author:BUGTian
 * @DATE: 2022/5/30
 */
@Data
public class LedgerManagementVO {

    /**
     * 用户编号
     */
    @Csv(name = "用户编号", type = CsvConstant.CSV_TYPE_WITHOUT)
    private String userNO;


    /**
     * 用户名称
     */
    @Csv(name = "用户名称", type = CsvConstant.CSV_TYPE_WITHOUT)
    private String userName;

    /**
     * 区域
     */
    private Integer accountId;
    /**
     * 品牌id
     */
    private Integer brandId;

    /**
     * 订单时间
     */
    @Excel(name = "订单时间", dateFormat = "yyyy-MM-dd HH:mm:ss", sort = 5)
    @Csv(name = "订单时间", type = CsvConstant.CSV_TYPE_WITHOUT)
    private Date addTime;

    /**
     * 业务类型
     */
    @Csv(name = "业务类型", keys = {"1", "2"}, values = {"运营分账", "押金分账"}, type = CsvConstant.CSV_TYPE_WITHOUT)
    private Integer buyOrderTypeGroup;

    /**
     * 分账金额
     */
    private Integer rechargeMoney;

    /**
     * 账户收入
     */
    private Integer money;


    /**
     * 账户支出
     */
    private Integer refundMoney;

    /**
     * 手续费
     */
    private Integer fee;


    /**
     * 汇付返还手续费
     */
    private Integer refundFee;


    /**
     * 服务费用
     */
    private Integer serviceFee;

    /**
     * 汇付到账
     */
    private Integer amountReceived;


   /**
    * ===以下是导出相关转换===
    */

   @Excel(name = "区域", sort = 2)
   @Csv(name = "区域", type = CsvConstant.CSV_TYPE_WITHOUT)
   private String areaName;
   /**
     * 分账金额
     */
    @JSONField(serialize = false)
    @Csv(name = "分账金额", type = CsvConstant.CSV_TYPE_WITHOUT)
    @Sum
    private String rechargeMoneyYuan;

    /**
     * 账户收入
     */
    @JSONField(serialize = false)
    @Csv(name = "账户收入", type = CsvConstant.CSV_TYPE_WITHOUT)
    @Sum
    private String moneyYuan;


    /**
     * 账户支出
     */
    @JSONField(serialize = false)
    @Csv(name = "账户支出", type = CsvConstant.CSV_TYPE_WITHOUT)
    @Sum
    private String refundMoneyYuan;

    /**
     * 手续费
     */
    @JSONField(serialize = false)
    @Csv(name = "手续费", type = CsvConstant.CSV_TYPE_WITHOUT)
    @Sum
    private String feeYuan;


    /**
     * 汇付返还手续费
     */
    @JSONField(serialize = false)
    @Csv(name = "汇付返还手续费", type = CsvConstant.CSV_TYPE_WITHOUT)
    @Sum
    private String refundFeeYuan;


    /**
     * 服务费用
     */
    @JSONField(serialize = false)
    @Csv(name = "服务费用", type = CsvConstant.CSV_TYPE_WITHOUT)
    @Sum
    private String serviceFeeYuan;


    @Excel(name = "汇付到账", sort = 2)
    @Csv(name = "汇付到账", type = CsvConstant.CSV_TYPE_WITHOUT)
    @Sum
    private String amountReceivedYuan;



    /**
     * 单位转换
     */
    public void unitConversion() {
        this.serviceFeeYuan = String.format("%.2f", ((double) serviceFee / 100D));
        this.feeYuan = String.format("%.2f", ((double) fee / 100D));
        this.refundMoneyYuan = String.format("%.2f", ((double) refundMoney / 100D));
        this.refundFeeYuan = String.format("%.2f", ((double) refundFee / 100D));
        this.moneyYuan = String.format("%.2f", ((double) money / 100D));
        this.rechargeMoneyYuan = String.format("%.2f", ((double) rechargeMoney / 100D));
        this.amountReceivedYuan = String.format("%.2f", ((double) amountReceived / 100D));
    }
}
